package com.zhou.framework.quartz.common;


import com.zhou.util.Assert;
import com.zhou.framework.quartz.model.JobConfig;

/**
 * @author lang.zhou
 * @date 2019/12/21
 */
public class JobConfigCheck {
    // 任务组
    public static final String DEFAULT_JOB_GROUP_NAME = "DEFAULT_JOB_GROUP_NAME";
    // 触发器组
    public static final String DEFAULT_TRIGGER_GROUP_NAME = "DEFAULT_TRIGGER_GROUP_NAME";
    public static JobConfig check(JobConfig config){
        Assert.notNull(config," config must not be empty ");
        Assert.notEmpty(config.getJobName()," job name must not be empty ");
        Assert.notEmpty(config.getCron()," job cron must not be empty ");
        Assert.notEmpty(config.getJobGroupName()," job group name must not be empty ");
        Assert.notEmpty(config.getTriggerGroupName()," trigger group name must not be empty ");
        Assert.notNull(config.getClazz()," job class must not be null ");
        return config;
    }
    public static JobConfig newJob(String jobName){
        return newJob(jobName,jobName);
    }

    public static JobConfig newJob(String jobName,String triggerName){
        JobConfig config = new JobConfig();
        config.setJobGroupName(DEFAULT_JOB_GROUP_NAME);
        config.setTriggerGroupName(DEFAULT_TRIGGER_GROUP_NAME);
        config.setTriggerName(triggerName);
        config.setJobName(jobName);
        return config;
    }
}
